function [kinematics_final] = kinematics_mean_std(kinematics_each_trial,trajectory)

% calculate similarity.

[ Cos_sim_mean,Cos_sim_std,RMSe_mean,RMSe_std ] = trajectory_similarity( trajectory );
kinematics_final.traj_sim_Cos__mean = Cos_sim_mean;
kinematics_final.traj_sim_Cos__std = Cos_sim_std;
kinematics_final.traj_sim_RMSe__mean = RMSe_mean;
kinematics_final.traj_sim_RMSe__std = RMSe_std;

% calculate mean & std
len = length(kinematics_each_trial);
R2 = zeros(len,1);
peak = zeros(len,1);
h_endpoint = zeros(len,1);
s_endpoint = zeros(len,1);
e_angle = zeros(len,1);
s_angle = zeros(len,1);

for i = 1:1:len
    R2(i,1)  = kinematics_each_trial(i).velocity_gaussian_R2;
    peak(i,1) = kinematics_each_trial(i).hand_peak_velocity;
    h_endpoint(i,1) = kinematics_each_trial(i).hand_endpoint;
    s_angle(i,1) =  kinematics_each_trial(i).shoulder_flextion_angle;
    e_angle(i,1) = kinematics_each_trial(i).elbow_flextion_angle;
    s_endpoint(i,1) = kinematics_each_trial(i).acromine_endpoint;
end

kinematics_final.velocity_gaussian_R2_mean = mean(R2);
kinematics_final.velocity_gaussian_R2_std = std(R2);

kinematics_final.hand_peak_velocity_mean = mean(peak);
kinematics_final.hand_peak_velocity_std = std(peak);

kinematics_final.hand_endpoint_mean = mean(h_endpoint);
kinematics_final.hand_endpoint_std = std(h_endpoint);

kinematics_final.shoulder_flextion_angle_mean = mean(s_angle);
kinematics_final.shoulder_flextion_angle_std = std(s_angle);

kinematics_final.elbow_flextion_angle_mean = mean(e_angle);
kinematics_final.elbow_flextion_angle_std = std(e_angle);

kinematics_final.acromine_endpoint_mean = mean(s_endpoint);
kinematics_final.acromine_endpoint_std = std(s_endpoint);
end

